package com.gzz.orchid.main.facade.controller;

import com.gzz.orchid.common.webmvc.support.HttpResult;
import com.gzz.orchid.main.facade.controller.pojo.AuthenticationRequest;
import com.gzz.orchid.main.facade.controller.pojo.RegisterRequest;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 *
 */
@RestController
@RequestMapping("/authentication")
@RequiredArgsConstructor
public class AuthenticationController {
    /**
     * 注册方法
     *
     * @param request 请求体
     */
    @PostMapping("/register")
    public HttpResult register(@RequestBody RegisterRequest request) {

        return HttpResult.success();
    }

    /**
     * 鉴权(登录方法)
     *
     * @param request 请求体
     */
    @PostMapping("/authenticate")
    public HttpResult authenticate(@RequestBody AuthenticationRequest request) {
        return HttpResult.success()
                .put("accessToken", "token")
                .put("refreshToken", "token");
    }

    /**
     * 刷新token
     *
     * @param request  请求体
     * @param response 响应体
     * @throws IOException 异常
     */
    @PostMapping("/refresh-token")
    public HttpResult refreshToken(HttpServletRequest request, HttpServletResponse response) throws IOException {
        return HttpResult.success();
    }
}
